/*
 * Copyright (C) 2018 Spreadtrum Communications Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <stdio.h>
#include <string.h>
#include "display_common.h"
#include "securec.h"
#include "sprd_drm_gsp.h"
#include "gsp_cfg.h"
#include "gsp_r9p0_cfg.h"
#include "gsp_r9p0_common.h"
#include "v1_0/display_composer_type.h"
namespace OHOS {
namespace HDI {
namespace DISPLAY {
using namespace OHOS::HDI::Display::Composer::V1_0;
#define GSP_QOGIRN6PRO "qogirn6pro"
#define GSP_QOGIRN6L "qogirn6l"

struct gsp_r9p0_capability mCapability;
uint16_t mLayerCount = 0;
bool mInputRotMode = false;

int get_tap_var0(int srcPara, int destPara)
{
  int retTap = 0;
  if ((srcPara < 3 * destPara) && (destPara <= 4 * srcPara))
    retTap = 4;
  else if ((srcPara >= 3 * destPara) && (srcPara < 4 * destPara))
    retTap = 6;
  else if (srcPara == 4 * destPara)
    retTap = 8;
  else if ((srcPara > 4 * destPara) && (srcPara < 6 * destPara))
    retTap = 4;
  else if ((srcPara >= 6 * destPara) && (srcPara < 8 * destPara))
    retTap = 6;
  else if (srcPara == 8 * destPara)
    retTap = 8;
  else if ((srcPara > 8 * destPara) && (srcPara < 12 * destPara))
    retTap = 4;
  else if ((srcPara >= 12 * destPara) && (srcPara < 16 * destPara))
    retTap = 6;
  else if (srcPara == 16 * destPara)
    retTap = 8;
  else
    retTap = 2;

  retTap = (8 - retTap) / 2;
  // retTap = 3 is null for htap & vtap on r9p0

  return retTap;
}

bool checkRangeSize(IRect *srcRect, IRect *dstRect)
{
  bool result = true;
  // Source and destination rectangle size check.
  if (srcRect->w < mCapability.common.crop_min.rect_w ||
      srcRect->h < mCapability.common.crop_min.rect_h ||
      srcRect->w > mCapability.common.crop_max.rect_w ||
      srcRect->h > mCapability.common.crop_max.rect_h || dstRect->w < mCapability.common.out_min.rect_w ||
      dstRect->h < mCapability.common.out_min.rect_h || dstRect->w > mCapability.common.out_max.rect_w ||
      dstRect->h > mCapability.common.out_max.rect_h) {
    DISPLAY_LOGD("clip or dst rect is not supported.");
    result = false;
  }

  return result;
}

enum gsp_rot_angle rotationTypeConvert(TransformType value)
{
  enum gsp_rot_angle rot = GSP_ROT_ANGLE_0;
  switch(value)
  {
    case ROTATE_NONE: 
        rot = GSP_ROT_ANGLE_0;
        break;
    case ROTATE_90: 
        rot = GSP_ROT_ANGLE_270;
        break;
    case ROTATE_180:
        rot = GSP_ROT_ANGLE_180;
        break;
    case ROTATE_270:
        rot = GSP_ROT_ANGLE_90;
        break;
    case MIRROR_H:
        rot =  GSP_ROT_ANGLE_180_M;
        break;
    case MIRROR_V:
        rot =  GSP_ROT_ANGLE_0_M;
        break;
    case MIRROR_H_ROTATE_90:
        rot =  GSP_ROT_ANGLE_270_M;
        break;
    case MIRROR_V_ROTATE_90:
        rot =  GSP_ROT_ANGLE_90_M;
        break;
    default:
        rot = GSP_ROT_ANGLE_MAX_NUM;
        break;
  }

  return rot;
}

int convertImgFormat(PixelFormat enColorFmt, struct gsp_layer_user *common,
                    struct gsp_r9p0_img_layer_params *params, uint32_t w, uint32_t h)
{
    int format = GSP_R9P0_IMG_FMT_MAX_NUM;
    uint32_t pixel_cnt = w * h;
    common->offset.v_offset = common->offset.uv_offset = pixel_cnt;

    params->endian.uv_dword_endn = GSP_R9P0_DWORD_ENDN_0;
    params->endian.uv_word_endn = GSP_R9P0_WORD_ENDN_0;
    params->endian.y_rgb_dword_endn = GSP_R9P0_DWORD_ENDN_0;
    params->endian.y_rgb_word_endn = GSP_R9P0_WORD_ENDN_0;
    params->endian.a_swap_mode = GSP_R9P0_A_SWAP_ARGB;
    switch(enColorFmt) {
        //代表gsp
        case PIXEL_FMT_RGBA_8888:
            format = GSP_R9P0_IMG_FMT_ARGB888;
            params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_BGR;
            break;
        case PIXEL_FMT_BGRA_8888:
            format = GSP_R9P0_IMG_FMT_ARGB888;
            params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_RGB;
            break;
        case PIXEL_FMT_RGBX_8888:
            format = GSP_R9P0_IMG_FMT_RGB888;
            params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_BGR;
            break;
        case PIXEL_FMT_RGB_565:
            format = GSP_R9P0_IMG_FMT_RGB565;
            params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_RGB;
            break;
        case PIXEL_FMT_YCBCR_420_SP:
            format = GSP_R9P0_IMG_FMT_YUV420_2P;
            params->endian.uv_word_endn = GSP_R9P0_WORD_ENDN_0;
            params->endian.y_rgb_word_endn = GSP_R9P0_WORD_ENDN_0;
            params->endian.a_swap_mode = GSP_R9P0_A_SWAP_ARGB;
            break;
        case PIXEL_FMT_YCRCB_420_SP:
            format = GSP_R9P0_IMG_FMT_YUV420_2P;
            params->endian.uv_word_endn = GSP_R9P0_WORD_ENDN_3;
            break;
        // case PIXEL_FMT_YCBCR_422_P:
        //    format = GSP_R9P0_IMG_FMT_YUV422_2P;
        //    break;
        case PIXEL_FMT_YCRCB_420_P: // YUV420_3P, Y V U
            format = GSP_R9P0_IMG_FMT_YV12;
            common->offset.uv_offset += (h + 1) / 2 * ((w + 1) / 2);//(height + 1) / 2 * ALIGN((width + 1) / 2, 16);
            params->endian.uv_word_endn = GSP_R9P0_WORD_ENDN_0;
            params->endian.y_rgb_word_endn = GSP_R9P0_WORD_ENDN_0;
            params->endian.a_swap_mode = GSP_R9P0_A_SWAP_ARGB;
            break;
        default: return -1;
    }
    return format;
}

int osdFormatConvert(PixelFormat enColorFmt, struct gsp_r9p0_osd_layer_params *params, struct gsp_layer_user *common)
{
    int format = GSP_R9P0_OSD_FMT_MAX_NUM;
    common->offset.v_offset = common->offset.uv_offset = 0;

    params->endian.y_rgb_word_endn = GSP_R9P0_WORD_ENDN_0;
    params->endian.y_rgb_dword_endn = GSP_R9P0_DWORD_ENDN_0;
    params->endian.y_rgb_qword_endn = GSP_R9P0_QWORD_ENDN_0;
    params->endian.a_swap_mode = GSP_R9P0_A_SWAP_ARGB;
    switch (enColorFmt)
    {
    case PIXEL_FMT_RGBA_8888:
        format = GSP_R9P0_OSD_FMT_ARGB888;
        params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_BGR;
        break;
    case PIXEL_FMT_BGRA_8888:
        format = GSP_R9P0_OSD_FMT_ARGB888;
        params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_RGB;
        break;
    case PIXEL_FMT_RGBX_8888:
        format = GSP_R9P0_OSD_FMT_RGB888;
        params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_BGR;
        break;
    case PIXEL_FMT_BGRX_8888:
        format = GSP_R9P0_OSD_FMT_RGB888;
        params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_RGB;
        break; 
    case PIXEL_FMT_RGB_565:
        format = GSP_R9P0_OSD_FMT_RGB565;
        params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_RGB;
        break;
    default:
        DISPLAY_LOGD("osd configEndian, unsupport format=0x%x.", format);
        break;
    }

    return format;
}

int dstFormatConvert(PixelFormat enColorFmt, struct gsp_r9p0_des_layer_params *params, struct gsp_layer_user *common,
                    uint32_t w, uint32_t h)
{
    int format = GSP_R9P0_DST_FMT_MAX_NUM;
    params->endian.uv_dword_endn = GSP_R9P0_DWORD_ENDN_0;
    params->endian.uv_word_endn = GSP_R9P0_WORD_ENDN_0;
    params->endian.y_rgb_dword_endn = GSP_R9P0_DWORD_ENDN_0;
    params->endian.y_rgb_word_endn = GSP_R9P0_WORD_ENDN_0;
    params->endian.a_swap_mode = GSP_R9P0_A_SWAP_ARGB;
    switch (enColorFmt) {
    case PIXEL_FMT_YCBCR_420_SP:
        format = GSP_R9P0_DST_FMT_YUV420_2P;
        params->endian.a_swap_mode = GSP_R9P0_A_SWAP_ARGB;
        break;
    case PIXEL_FMT_YCBCR_422_P:
        format = GSP_R9P0_DST_FMT_YUV422_2P;
        break;
    case PIXEL_FMT_YCRCB_420_P:
        format = GSP_R9P0_DST_FMT_YUV420_3P;
        params->endian.uv_word_endn = GSP_R9P0_WORD_ENDN_3;
        break;
    case PIXEL_FMT_RGBA_8888:
        format = GSP_R9P0_DST_FMT_ARGB888;
        params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_BGR;
        break;
    case PIXEL_FMT_RGB_565:
        format = GSP_R9P0_DST_FMT_RGB565;
        params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_RGB;
        break;
    case PIXEL_FMT_RGBX_8888:
        format = GSP_R9P0_DST_FMT_RGB888;
        params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_BGR;
        break;
    case PIXEL_FMT_BGRA_8888:
        format = GSP_R9P0_DST_FMT_ARGB888;
        params->endian.rgb_swap_mode = GSP_R9P0_RGB_SWP_RGB;
        break;
    default:
        DISPLAY_LOGD("dst configEndian, unsupport format=0x%x.", enColorFmt);
        break;
    }
    common->offset.uv_offset = w * h;
    common->offset.v_offset = w * h;
    
    return format;
}

bool isVideoLayerImg(int format)
{
  bool result = false;

  if ((format >= GSP_R9P0_IMG_FMT_YUV422_2P &&
       format <= GSP_R9P0_IMG_FMT_YUV420_3P) ||
      (format == GSP_R9P0_IMG_FMT_YV12))
    result = true;

  return result;
}

bool isVideoLayerOsd(int format)
{
  bool result = false;

  if (format > GSP_R9P0_OSD_FMT_RGB565)
    result = true;

  return result;
}

bool imgCheckOddBoundary(IRect *srcRect, int32_t format)
{
  bool result = true;

  // if yuv_xywh_even == 1, gsp do not support odd source layer.
  if (isVideoLayerImg(format) == true && !mCapability.yuv_xywh_even) {
    if ((srcRect->x & 0x1) || (srcRect->y & 0x1) || (srcRect->w & 0x1) ||
        (srcRect->h & 0x1)) {
      DISPLAY_LOGD("do not support odd source layer xywh.");
      result = false;
    }
  }

  return result;
}

bool isLandScapeTransform(enum gsp_rot_angle rot) 
{
  bool result = false;

  if (rot == GSP_ROT_ANGLE_90 || rot == GSP_ROT_ANGLE_270 ||
      rot == GSP_ROT_ANGLE_90_M || rot == GSP_ROT_ANGLE_270_M)
    result = true;

  return result;
}


bool checkScaleSize(IRect *srcRect, IRect *dstRect,
                    enum gsp_rot_angle rot, bool inFBC,
                    int protectLayerNum) 
{
  bool result = true;

  uint16_t scaleUpLimit = (inFBC ? 24 : (mCapability.scale_range_up / 4));
  uint16_t scaleDownLimit = (inFBC ? 4 : (16 / mCapability.scale_range_down));

  uint32_t srcw = 0;
  uint32_t srch = 0;
  uint32_t dstw = dstRect->w;
  uint32_t dsth = dstRect->h;

  if (protectLayerNum >= 0) {
    scaleDownLimit = 12;
    scaleUpLimit = 12;
  }

  if ((mLayerCount >= 6) && (inFBC == 0)) {
    scaleDownLimit = 12;
  }

  if (isLandScapeTransform(rot) == true) {
    srcw = srcRect->h;
    srch = srcRect->w;
  } else {
    srcw = srcRect->w;
    srch = srcRect->h;
  }

  if (scaleUpLimit * srcw < dstw || scaleUpLimit * srch < dsth ||
      scaleDownLimit * dstw < srcw || scaleDownLimit * dsth < srch) {
    // gsp support [1/16-gsp_scaling_up_limit] scaling
    DISPLAY_LOGD("GSP only support %d-%d scaling!", scaleDownLimit,
             scaleUpLimit);
    result = false;
  } else {
    if ((protectLayerNum >= 0) && (srcw * 4 < dstw || srch * 4 < dsth ||
                                   dstw * 4 < srcw || dsth * 4 < srch)) {
      DISPLAY_LOGD("GSP need scale twice");
    //   mScaleTwice = true;
    }
  }

  return result;
}

bool checkScale(IRect *srcRect, IRect *dstRect,
                enum gsp_rot_angle rot, bool inFBC,
                int protectLayerNum)
{
  uint32_t srcw = 0;
  uint32_t srch = 0;
  uint32_t dstw = dstRect->w;
  uint32_t dsth = dstRect->h;

  if (isLandScapeTransform(rot) == true) {
    srcw = srcRect->h;
    srch = srcRect->w;
  } else {
    srcw = srcRect->w;
    srch = srcRect->h;
  }

  if ((mCapability.scale_updown_sametime == false) &&
      ((srcw < dstw && srch > dsth) || (srcw > dstw && srch < dsth))) {
    DISPLAY_LOGD("need scale up and down at same time, which not support");
    return false;
  }

  if (checkScaleSize(srcRect, dstRect, rot, inFBC, protectLayerNum) == false)
    return false;

  return true;
}

bool checkInputRotation(IRect *srcRect, IRect *dstRect, enum gsp_rot_angle rot,
                        int32_t format, int protectLayerNum)
{
  bool result = true;

  uint16_t scaleUpLimit = 24;
  uint16_t scaleDownLimit = 4;

  if (protectLayerNum >= 0) {
    scaleDownLimit = 16;
    scaleUpLimit = 16;
  }

  uint32_t srcw = 0;
  uint32_t srch = 0;
  uint32_t dstw = dstRect->w;
  uint32_t dsth = dstRect->h;

  if (isLandScapeTransform(rot) == true) {
    srcw = srcRect->h;
    srch = srcRect->w;
  } else {
    srcw = srcRect->w;
    srch = srcRect->h;
  }

  if (scaleUpLimit * srcw < dstw || scaleUpLimit * srch < dsth ||
      scaleDownLimit * dstw < srcw || scaleDownLimit * dsth < srch) {
    DISPLAY_LOGD("GSP input rotation only support %d-%d scaling!",
             scaleDownLimit, scaleUpLimit);
    return false;
  }

  if (rot != 0) {
    switch (format) {
    case GSP_R9P0_IMG_FMT_YUV420_2P:
    case GSP_R9P0_IMG_FMT_YV12:
    case GSP_R9P0_IMG_FMT_ARGB888:
    case GSP_R9P0_IMG_FMT_RGB888:
    case GSP_R9P0_IMG_FMT_RGB565:
    case GSP_R9P0_IMG_FMT_YCBCR_P010:
      break;
    default:
      DISPLAY_LOGD("input rotation unsupport img format:0x%x.", format);
      result = false;
      break;
    }
  }

  if (rot != 0 && (srcw != dstw || srch != dsth)) {
    switch (format) {
    case GSP_R9P0_IMG_FMT_ARGB888:
    case GSP_R9P0_IMG_FMT_RGB888:
    case GSP_R9P0_IMG_FMT_RGB565:
    case GSP_R9P0_IMG_FMT_YUV420_2P:
    case GSP_R9P0_IMG_FMT_YV12:
    case GSP_R9P0_IMG_FMT_YCBCR_P010:
      break;
    default:
      DISPLAY_LOGD("input rotation  scaling unsupport img format:0x%x.",
               format);
      result = false;
      break;
    }
  }

  return result;
}

bool needScale(IRect *srcRect, IRect *dstRect,
                enum gsp_rot_angle rot) 
{
  bool result = false;

  if (isLandScapeTransform(rot) == true) {
    if (srcRect->w != dstRect->h || srcRect->h != dstRect->w)
      result = true;
  } else {
    if (srcRect->w != dstRect->w || srcRect->h != dstRect->h)
      result = true;
  }

  return result;
}

void configScale(IRect *srcRect, IRect *dstRect, enum gsp_rot_angle rot, 
                    struct  gsp_r9p0_img_layer_params *params)
{
  uint32_t dstw = 0;
  uint32_t dsth = 0;

  if (needScale(srcRect, dstRect, rot) == true) {
    params->scaling_en = 1;
    params->scale_para.scale_en = 1;

    params->scale_para.scale_rect_in.st_x = srcRect->x;
    params->scale_para.scale_rect_in.st_y = srcRect->y;
    params->scale_para.scale_rect_in.rect_w = srcRect->w;
    params->scale_para.scale_rect_in.rect_h = srcRect->h;

    params->scale_para.scale_rect_out.st_x = dstRect->x;
    params->scale_para.scale_rect_out.st_y = dstRect->y;
    params->scale_para.scale_rect_out.rect_w = dstRect->w;
    params->scale_para.scale_rect_out.rect_h = dstRect->h;

    if (isLandScapeTransform(rot) == true) {
      dstw = params->scale_para.scale_rect_out.rect_h;
      dsth = params->scale_para.scale_rect_out.rect_w;
    } else {
      dstw = params->scale_para.scale_rect_out.rect_w;
      dsth = params->scale_para.scale_rect_out.rect_h;
    }

    params->scale_para.htap_mod =
        get_tap_var0(params->scale_para.scale_rect_in.rect_w, dstw);

    params->scale_para.vtap_mod =
        get_tap_var0(params->scale_para.scale_rect_in.rect_h, dsth);
  }

  /*for output rotation dst coordinate calucuate, "rotAdjustSingle" */
  params->scale_para.scale_rect_out.rect_w = dstRect->w;
  params->scale_para.scale_rect_out.rect_h = dstRect->h;
}


static int rotAdjustSingle(uint16_t *dx, uint16_t *dy, uint16_t *dw,
                    uint16_t *dh, uint32_t pitch,
                    uint32_t height, uint32_t transform)
{
  uint32_t x = *dx;
  uint32_t y = *dy;

  /*first adjust dest x y*/
  switch (transform) {
  case 0:
    break;
  case MIRROR_H: // 1
    *dx = pitch - x - *dw;
    break;
  case MIRROR_V: // 2
    *dy = height - y - *dh;
    break;
  case ROTATE_180: // 3
    *dx = pitch - x - *dw;
    *dy = height - y - *dh;
    break;
  case ROTATE_90: // 4
    *dx = y;
    *dy = pitch - x - *dw;
    break;
  case MIRROR_H_ROTATE_90: // 5
    *dx = height - y - *dh;
    *dy = pitch - x - *dw;
    break;
  case MIRROR_V_ROTATE_90: // 6
    *dx = y;
    *dy = x;
    break;
  case ROTATE_270: // 7
    *dx = height - y - *dh;
    *dy = x;
    break;
  default:
    DISPLAY_LOGD("rotAdjustSingle, unsupport angle=%d.", transform);
    break;
  }

  /*then adjust dest width height*/
  if (transform & ROTATE_90) {
    uint16_t tmp = *dw;
    *dw = *dh;
    *dh = tmp;
  }

  return 0;
}

int rotAdjust(struct gsp_r9p0_cfg_user *cmd_info, uint32_t transform)
{
  int32_t ret = 0;
  uint16_t w = 0;
  uint16_t h = 0;
  int32_t icnt = 0;
  struct gsp_r9p0_osd_layer_user *osd_info = NULL;
  struct gsp_r9p0_img_layer_user *img_info = NULL;

  img_info = cmd_info->limg;
  for (icnt = 0; icnt < R9P0_IMGL_NUM; icnt++) {
    if (img_info[icnt].common.enable == 1) {
      ret = rotAdjustSingle(
          &img_info[icnt].params.des_rect.st_x,
          &img_info[icnt].params.des_rect.st_y,
          &img_info[icnt].params.scale_para.scale_rect_out.rect_w,
          &img_info[icnt].params.scale_para.scale_rect_out.rect_h,
          cmd_info->ld1.params.pitch, cmd_info->ld1.params.height, transform);
      if (ret) {
        DISPLAY_LOGD("rotAdjust img layer[%d] rotation adjust failed, ret=%d.", icnt,
              ret);
        return ret;
      }
    }
  }

  osd_info = cmd_info->losd;
  for (icnt = 0; icnt < R9P0_OSDL_NUM; icnt++) {
    if (osd_info[icnt].common.enable == 1) {
      w = osd_info[icnt].params.clip_rect.rect_w;
      h = osd_info[icnt].params.clip_rect.rect_h;
      if (transform & ROTATE_90) {
        uint16_t tmp = w;
        w = h;
        h = tmp;
      }
      ret = rotAdjustSingle(&osd_info[icnt].params.des_pos.pt_x,
                            &osd_info[icnt].params.des_pos.pt_y, &w, &h,
                            cmd_info->ld1.params.pitch,
                            cmd_info->ld1.params.height, transform);
      if (ret) {
        DISPLAY_LOGD("rotAdjust OSD[%d] rotation adjust failed, ret=%d.", icnt, ret);
        return ret;
      }
    }
  }

  if (transform & ROTATE_90) {
    uint16_t tmp = cmd_info->ld1.params.pitch;
    cmd_info->ld1.params.pitch = cmd_info->ld1.params.height;
    cmd_info->ld1.params.height = tmp;
    tmp = cmd_info->misc.workarea_src_rect.rect_w;
    cmd_info->misc.workarea_src_rect.rect_w = cmd_info->misc.workarea_src_rect.rect_h;
    cmd_info->misc.workarea_src_rect.rect_h = tmp;
  }
  return ret;
}


bool miscCfgParcel(struct gsp_r9p0_misc_cfg_user *r9p0_misc_cfg, int mode_type, uint32_t transform, 
                    uint32_t w, uint32_t h) 
{
  bool status = false;
  uint32_t freq = GSP_R9P0_FREQ_256M;

  switch (mode_type) {
  case 0: {
    /* run_mod = 0, scale_seq = 0 */
    r9p0_misc_cfg->work_mod = 0;
    r9p0_misc_cfg->core_num = 0;

    r9p0_misc_cfg->workarea_src_rect.st_x = 0;
    r9p0_misc_cfg->workarea_src_rect.st_y = 0;
    r9p0_misc_cfg->workarea_src_rect.rect_w = w;
    r9p0_misc_cfg->workarea_src_rect.rect_h = h;

    r9p0_misc_cfg->secure_en = 0;

    freq = GSP_R9P0_FREQ_512M;

    /*set gsp freq = 512M when gsp open dual core*/
    if (r9p0_misc_cfg->core_num)
      freq = GSP_R9P0_FREQ_512M;

    if (strcmp(GSP_QOGIRN6L, mCapability.board) == 0) {
      freq = GSP_R9P0_FREQ_614_4M;
    }

    r9p0_misc_cfg->work_freq = freq;
    DISPLAY_LOGD("config frequency Index : 0x%d", freq);

    // if (inquireScaleTwice() == false) //暂时未处理
    //   hdrParaParcel(source, &r9p0_misc_cfg);

    }
    r9p0_misc_cfg->workarea_des_pos.pt_x = 0;
    r9p0_misc_cfg->workarea_des_pos.pt_y = 0;
    status = true;
    break;
  default:
    DISPLAY_LOGD("gsp r9p0 not implement other mode(%d) yet! ", mode_type);
    break;
  }

  return status;
}
} // namespace DISPLAY
} // namespace HDI
} // namespace OHOS
